package cn.edu.java.io.outputstream.filteroutputstream;

import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class DataOutputStreamDemo {
    public static void main(String[] args) {
        String fileName = "input/data.bin";

        try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(fileName))) {
            // 写入不同类型的数据
            dos.writeInt(42);
            dos.writeDouble(3.14);
            dos.writeBoolean(true);
            dos.writeUTF("Hello, world!");

            System.out.println("数据写入完成！");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

